﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Admincp/Admin.Master" AutoEventWireup="true"
    CodeBehind="Hoadonban.aspx.cs" Inherits="TPCN.Admincp.Hoadonban" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
</asp:Content>
<asp:Content ID="name" ContentPlaceHolderID="nameholder" runat="server">
    Hóa đơn bán</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="maincontent" runat="server">
    <!-- Script manager -->
    <telerik:RadScriptManager ID="RadScriptManager1" runat="server">
        <Scripts>
            <asp:ScriptReference Assembly="Telerik.Web.UI" Name="Telerik.Web.UI.Common.Core.js" />
        </Scripts>
    </telerik:RadScriptManager>
    <!-- Button Panel -->
    <asp:Panel ID="ButtonPanel" runat="server" CssClass="right">
        <asp:Button ID="btnInsert" runat="server" Text="Thêm mới" CssClass="button button-green"
            OnClick="btnInsert_Click" />
        <asp:Button ID="btnDelete" runat="server" Text="Xóa" CssClass="button button-green"
            OnClick="btnDelete_Click" OnClientClick="if(!confirm('Bạn có muốn xóa những dòng đã chọn không?')) return false;" />
    </asp:Panel>
    <asp:Panel ID="ErrorPanel" runat="server">
        <asp:ValidationSummary ID="summary" runat="server" CssClass="message error" />
    </asp:Panel>
    <hr />
    <!-- Master -->
    <asp:Panel ID="GridViewPanel" runat="server">
        <asp:GridView ID="HBDGridView" runat="server" AutoGenerateColumns="False" Width="100%"
            DataKeyNames="HoadonbanID" Height="16px" OnRowCommand="HDBGridView_RowCommand"
            AllowPaging="True" GridLines="None" CssClass="mGrid" AlternatingRowStyle-CssClass="alt"
            PagerStyle-CssClass="pgr" OnPageIndexChanging="HDBGridView_PageIndexChanging"
            PageSize="15">
            <AlternatingRowStyle CssClass="alt" />
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkSelect" runat="server" CssClass="chkItem" />
                    </ItemTemplate>
                    <HeaderTemplate>
                        <asp:CheckBox ID="chkSelectAll" runat="server" CssClass="chkHeader" />
                    </HeaderTemplate>
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                </asp:TemplateField>
                <asp:BoundField DataField="HoadonbanID" HeaderText="Mã hóa đơn bán" ReadOnly="True">
                    <HeaderStyle CssClass="hide" />
                    <ItemStyle CssClass="hide" />
                </asp:BoundField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="cmdViewDetail" runat="server" CommandArgument='<%# Eval("HoadonbanID") %>'
                            CommandName="cmdViewDetail">Chi tiết</asp:LinkButton>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Ngày lập">
                    <ItemTemplate>
                        <asp:Literal ID="lblNgaylap" runat="server" Text='<%# FormatDatetime(Eval("Ngaylap")) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Khách hàng">
                    <ItemTemplate>
                        <asp:Literal ID="lblTenkhach" runat="server" Text='<%# GetCustomerNameById(Eval("KhachID")) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Hình thức chiết khấu">
                    <ItemTemplate>
                        <asp:Literal ID="lblHinhthucchietkhau" runat="server" Text='<%# GetDiscountNameByID(Eval("Hinhthucchietkhau")) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField HeaderText="Chiết khấu">
                    <ItemTemplate>
                        <asp:Literal ID="lblChietkhau" runat="server" Text='<%# FormatDiscount(Eval("Hinhthucchietkhau"), Eval("Chietkhau")) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:LinkButton ID="btn_CMD_Edit" runat="server" CommandArgument='<%# Eval("HoadonbanID") %>'
                            CommandName="cmdEdit">Sửa</asp:LinkButton>
                        <asp:LinkButton ID="btn_CMD_Delete" runat="server" CommandArgument='<%# Eval("HoadonbanID") %>'
                            CommandName="cmdDelete" OnClientClick="return confirm('Bạn có muốn xóa hóa đơn này không?');">Xóa</asp:LinkButton>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>
            </Columns>
            <HeaderStyle HorizontalAlign="Left" />
            <PagerSettings FirstPageText="Đầu" LastPageText="Cuối" Mode="NumericFirstLast" NextPageText="Tiếp"
                PreviousPageText="Trước" PageButtonCount="5" />
            <PagerStyle CssClass="pgr" />
        </asp:GridView>
    </asp:Panel>
    <asp:Panel ID="EditFormPanel" runat="server">
        <table id="EditForm">
            <tbody>
                <tr>
                    <td class="label">
                        Khách hàng
                    </td>
                    <td>
                        <asp:DropDownList ID="cboKhachhang" runat="server" Width="245px">
                        </asp:DropDownList>
                    </td>
                    <td class="label">
                        Ngày lập
                    </td>
                    <td>
                        <telerik:RadDatePicker ID="cboNgaylap" runat="server" Width="245px" Culture="vi-VN">
                            <Calendar UseColumnHeadersAsSelectors="False" UseRowHeadersAsSelectors="False" ViewSelectorText="x"
                                runat="server">
                            </Calendar>
                            <DateInput runat="server" DateFormat="dd/MM/yyyy" DisplayDateFormat="dd/MM/yyyy">
                            </DateInput>
                            <DatePopupButton HoverImageUrl="" ImageUrl="" />
                        </telerik:RadDatePicker>
                    </td>
                </tr>
                <tr>
                    <td class="label">
                        Hình thức chiết khấu
                    </td>
                    <td>
                        <asp:DropDownList ID="cboHinhthuchietkhau" runat="server" Width="245px">
                        </asp:DropDownList>
                    </td>
                    <td class="label">
                        Chiết khấu
                    </td>
                    <td>
                        <telerik:RadNumericTextBox ID="txtChietkhau" runat="server" Width="230px" EnableEmbeddedSkins="False"
                            EnableTheming="False" MinValue="0" Value="0" EnableEmbeddedBaseStylesheet="False">
                            <NumberFormat DecimalDigits="0" />
                            <EnabledStyle PaddingBottom="4px" PaddingLeft="6px" PaddingRight="6px" PaddingTop="4px" />
                        </telerik:RadNumericTextBox>
                    </td>
                </tr>
                <tr>
                    <td class="label top">
                        Nội dung chiết khấu
                    </td>
                    <td colspan="3">
                        <asp:TextBox ID="txtNoidungchietkhau" runat="server" TextMode="MultiLine" Width="550px"
                            Height="200px" />
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="center">
            <asp:Button ID="btnSave" runat="server" Text="Cập nhật" CssClass="button button-green groupbutton"
                OnClick="btnSave_Click" />
            <asp:Button ID="btnCancel" runat="server" Text="Hủy bỏ" CssClass="button button-green groupbutton"
                OnClick="btnCancel_Click" TabIndex="12" CausesValidation="False" UseSubmitBehavior="False"
                EnableViewState="False" />
        </div>
    </asp:Panel>
    <div class="clear">
    </div>
    <!-- Detail -->
    <asp:Panel ID="DetailGridPanel" runat="server">
        <asp:GridView ID="DetailGridView" runat="server" AutoGenerateColumns="False" Width="100%"
            DataKeyNames="ChitiethoadonbanID" Height="16px" AllowPaging="True" GridLines="None"
            CssClass="mGrid" AlternatingRowStyle-CssClass="alt" PagerStyle-CssClass="pgr"
            PageSize="15" OnPageIndexChanging="DetailGridView_PageIndexChanging" OnRowCommand="DetailGridView_RowCommand">
            <AlternatingRowStyle CssClass="alt" />
            <Columns>
                <asp:TemplateField>
                    <ItemTemplate>
                        <asp:CheckBox ID="chkSelect" runat="server" CssClass="chkItem" />
                    </ItemTemplate>
                    <HeaderTemplate>
                        <asp:CheckBox ID="chkSelectAll" runat="server" CssClass="chkHeader" />
                    </HeaderTemplate>
                    <HeaderStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                    <ItemStyle HorizontalAlign="Center" VerticalAlign="Middle" Width="30px" />
                </asp:TemplateField>
                <asp:BoundField DataField="ChitiethoadonbanID" ReadOnly="True">
                    <HeaderStyle CssClass="hide" />
                    <ItemStyle CssClass="hide" />
                </asp:BoundField>
                <asp:TemplateField HeaderText="Sản phẩm">
                    <ItemTemplate>
                        <asp:Literal ID="lblProductName" runat="server" Text='<%# GetProductNameById(Eval("HangID")) %>' />
                    </ItemTemplate>
                </asp:TemplateField>
                <asp:BoundField DataField="Soluong" HeaderText="Số lượng" />
                <asp:BoundField DataField="Dongia" HeaderText="Đơn giá" />
                <asp:TemplateField>
                    <ItemTemplate>
                         <asp:LinkButton ID="btn_CMD_Edit" runat="server" CommandArgument='<%# Eval("ChitiethoadonbanID") %>'
                            CommandName="cmdEdit">Sửa</asp:LinkButton>
                        <asp:LinkButton ID="btn_CMD_Delete" runat="server" CommandArgument='<%# Eval("ChitiethoadonbanID") %>'
                            CommandName="cmdDelete" OnClientClick="if(!confirm('Bạn có muốn xóa sản phẩm này không?')) return false;">Xóa</asp:LinkButton>
                    </ItemTemplate>
                    <ItemStyle HorizontalAlign="Center" />
                </asp:TemplateField>
            </Columns>
            <HeaderStyle HorizontalAlign="Left" />
            <PagerSettings FirstPageText="Đầu" LastPageText="Cuối" Mode="NumericFirstLast" NextPageText="Tiếp"
                PreviousPageText="Trước" PageButtonCount="5" />
            <PagerStyle CssClass="pgr" />
        </asp:GridView>
        <div class="backButton clear">
            <asp:Button ID="btnBack" runat="server" CssClass="button button-green" Text="Trở lại"
                OnClick="btnBack_Click" />
        </div>
    </asp:Panel>
    <asp:Panel ID="DetailEditPanel" runat="server">
        <table id="detailEdit">
            <tbody>
                <tr>
                    <td class="label">
                        Sản phẩm
                    </td>
                    <td>
                        <asp:DropDownList ID="cboProduct" runat="server" Width="245px">
                        </asp:DropDownList>
                    </td>
                    <td class="label">
                        Số lượng
                    </td>
                    <td>
                        <telerik:RadNumericTextBox ID="txtQuantity" runat="server" Width="230px" EnableEmbeddedSkins="False"
                            EnableTheming="False" MinValue="0" Value="0" EnableEmbeddedBaseStylesheet="False">
                            <NumberFormat DecimalDigits="0" />
                            <EnabledStyle PaddingBottom="4px" PaddingLeft="6px" PaddingRight="6px" PaddingTop="4px" />
                        </telerik:RadNumericTextBox>
                    </td>
                </tr>
                <tr>
                    <td class="label">
                        Đơn giá
                    </td>
                    <td colspan="3">
                        <telerik:RadNumericTextBox ID="txtPrice" runat="server" Width="230px" EnableEmbeddedSkins="False"
                            EnableTheming="False" MinValue="0" Value="0" EnableEmbeddedBaseStylesheet="False">
                            <NumberFormat DecimalDigits="0" />
                            <EnabledStyle PaddingBottom="4px" PaddingLeft="6px" PaddingRight="6px" PaddingTop="4px" />
                        </telerik:RadNumericTextBox>
                    </td>
                </tr>
            </tbody>
        </table>
        <div class="center">
            <asp:Button ID="DetailBtnSave" runat="server" Text="Cập nhật" CssClass="button button-green groupbutton"
                OnClick="btnSave_Click" />
            <asp:Button ID="DetailBtnCancel" runat="server" Text="Hủy bỏ" CssClass="button button-green groupbutton"
                OnClick="btnCancel_Click" TabIndex="12" CausesValidation="False" UseSubmitBehavior="False"
                EnableViewState="False" />
        </div>
    </asp:Panel>
    <div class="clear">
    </div>
    <!-- Ajax Manager -->
    <telerik:RadAjaxLoadingPanel ID="loadingPanel" runat="server" MinDisplayTime="0" />
    <telerik:RadAjaxManager ID="ajax" runat="server">
        <AjaxSettings>
            <telerik:AjaxSetting AjaxControlID="GridViewPanel">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="GridViewPanel" LoadingPanelID="loadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="EditFormPanel" LoadingPanelID="loadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="DetailGridPanel" LoadingPanelID="loadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="Buttonpanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
            <telerik:AjaxSetting AjaxControlID="ButtonPanel">
                <UpdatedControls>
                    <telerik:AjaxUpdatedControl ControlID="GridViewPanel" LoadingPanelID="loadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="EditFormPanel" LoadingPanelID="loadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="DetailGridPanel" LoadingPanelID="loadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="DetailEditPanel" LoadingPanelID="loadingPanel" />
                    <telerik:AjaxUpdatedControl ControlID="ButtonPanel" />
                </UpdatedControls>
            </telerik:AjaxSetting>
        </AjaxSettings>
    </telerik:RadAjaxManager>
</asp:Content>
